package com.ford.trade.jingcai;

import com.ford.trade.entity.JingCaiPeiLv;
import com.ford.trade.repository.JingCaiPeilvRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: ford
 * @date: 2022/4/25 12:03
 */
@Service
public class JingCaiPeilvServiceImpl implements JingCaiPeilvService {
    @Resource
    private JingCaiPeilvRepository jingCaiPeilvRepository;

    @Override
    public void save(JingCaiPeiLv peiLv) {
//        List<JingCaiPeiLv> allByIndexId = jingCaiPeilvRepository.findAllByIndexId(peiLv.getIndexId());
//        if (!CollectionUtils.isEmpty(allByIndexId)){
//            peiLv.setId(allByIndexId.get(0).getId());
//        }
        jingCaiPeilvRepository.save(peiLv);
    }

    @Override
    public List<JingCaiPeiLv> findByIndexId(Long indexId) {

        return jingCaiPeilvRepository.findAllByIndexId(indexId);
    }
}
